<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>dhtmlxVault文件上传</title>
		<meta name="author" content="Administrator" />
		<!-- Date: 2014-05-30 -->
		
		<link rel="stylesheet" type="text/css" href="../../resources/dhtmlxVault/codebase/dhtmlxvault.css" />
		<!--
		<link rel="stylesheet" type="text/css" href="../../resources/dhtmlxVault/themes/sky blue/dhtmlxvault.css" />
		-->
		<script type="text/javascript" src="../../resources/dhtmlxVault/codebase/dhtmlxvault.js"></script>

		<script type="text/javascript">
			var vault = null;
			function doOnLoad() {
				vault = new dhtmlXVaultObject();
				var basePath='../../resources/dhtmlxVault';
				vault.setImagePath(basePath+"/codebase/imgs/");
				vault.setServerHandlers(basePath+"/handlers/php_simple/UploadHandler.php", basePath+"/handlers/php_simple/GetInfoHandler.php", basePath+"/handlers/php_simple/GetIdHandler.php");
				vault.setWidth(700);
				vault.setHeight(200);
				//上传文件个数限制
				//vault.setFilesLimit(1);
				//限制文件类型
				// vault.onAddFile = function(fileName) {
	                // var ext = this.getFileExtension(fileName);
	                // if (ext != "txt" && ext != "doc") {
	                    // alert("You may upload only text documents (txt, doc). Please retry.");
	                    // return false;
	                // } else {
	                	// return true;
	                // }
		        // };

				//本地化
				vault.strings = {
					remove : "移除",
					done : "完成",
					error : "错误",
					btnAdd : "添加文件",
					btnUpload : "上传",
					btnClean : "清除"
				};
				
				//指定form字段
				vault.setFormField("customerId", "PS104");
	            vault.setFormField("country", "UK");
				//will remove this field from the form
	            vault.setFormField("groupId", null);   

				vault.strings.errors = {
					"TooBig" : "文件太大({0} bytes).\n允许的最大文件大小为 {1}.",
					"PostSize" : "无知服务器异常. 可能的原因为:\n" + "- 文件名未能被服务器正确处理;\n" + "- 文件的大小可能超过了服务器的请求限制 ({0})."
				};

				//
				
				/**
				 * 回调函数,每上传一个文件触发一次
				 */
				vault.onFileUploaded = function(file) {
					alert("id:" + file.id + ",name:" + file.name + ",uploaded:" + file.uploaded + ",error:" + file.error);
				};
				
				/**
				 * 所有文件上传完成才触发
				 */
				vault.onUploadComplete = function(files) {
	                var s="";
	                for (var i=0; i<files.length; i++) {
	                    var file = files[i];
	                    s += ("id:" + file.id + ",name:" + file.name + ",uploaded:" + file.uploaded + ",error:" + file.error)+"\n";
	                }
	                alert(s);
                };

				vault.create("vault1");
			}
		</script>

	</head>
	<body onload="doOnLoad()">
		<div id="vault1"> </div>
	</body>
</html>

